package Booking;
import  java.util.ArrayList;
import java.util.List;
//书架类
public class BookList {
    //书架类里面的内容要对所有人都可见，共享的
    private static List<Book> books = new ArrayList<>();
    private static List<String> booksName = new ArrayList<>();

    //使用static代码块初始化static变量
    static {
        books.add(new Book("三国演义", "罗贯中", 35, "小说"));
        books.add(new Book("水浒传", "施耐庵", 32, "小说"));
        books.add(new Book("红楼梦", "曹雪芹", 36, "小说"));
        books.add(new Book("西游记", "吴承恩", 35.5, "小说"));

        booksName.add("三国演义");
        booksName.add("红楼梦");
        booksName.add("水浒传");
        booksName.add("西游记");

    }

    public void displayBooks() {
        for (Book book : books) {
            System.out.println(book);
        }
    }

    public boolean contains(String booksName) {
        return BookList.booksName.contains(booksName);
    }

    public void add(Book book) {
        books.add(book);
        booksName.add(book.getBookName());
    }
}
